# $Id$

namespace :redmine_project_reports do
  task :add_test_data => :environment do
    project = Project.find_by_name("ProjectReportsTest")

    ProjectReportForm.destroy_all
    ProjectReportIssueGroup.destroy_all
    ProjectReportTeam.destroy_all
    ProjectReport.destroy_all

    form = ProjectReportForm.new
    form.name = "ProjectReportSample-01"
    form.project = project

    group = ProjectReportIssueGroup.new
    group.project = project
    group.form = form
    group.query = Query.find(3)
    form.issue_groups << group
    form.save!
    group.save!

    group = ProjectReportIssueGroup.new
    group.project = project
    group.form = form
    group.query = Query.find(4)
    form.issue_groups << group
    form.save!
    group.save!

    team = ProjectReportTeam.new
    team.name = "Team-01"
    team.project = project
    team.form = form
    team.members << User.find_by_login("admin")
    team.members << User.find_by_login("and")
    form.teams << team
    form.save!
    team.save!

    report = ProjectReport.new
    report.project = project
    report.form = form
    report.start_date = "2010-05-01"
    report.due_date = "2010-06-30"

    report.save!

  end
end
